

import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)



//创建路由表
const routes = [
  { path: '/', redirect: '/index' },
  {
    path: '/index',
    component: () => import('../views/index'),
    redirect: '/index/banners',
    meta: { title: '首页' },
    children: [

      {
        path: 'banners',
        meta: { title: '轮播图管理' },
        component: () => import('../views/shouye/banner'),
        beforeEnter: (to, from, next) => {
          // reject the navigation
          console.log('独享守卫');
          next()
        }

      },
      { path: 'category', meta: { title: '分类管理' }, component: () => import('../views/shouye/category') },
      { path: 'recommend', meta: { title: '为你推荐管理' }, component: () => import('../views/shouye/recommend') },
      { path: 'brand', meta: { title: '品牌管理' }, component: () => import('../views/shangpin/brand') },
      { path: 'classify', meta: { title: '分类管理' }, component: () => import('../views/shangpin/classify') },
      { path: 'products', meta: { title: '商品管理' }, component: () => import('../views/shangpin/products') },
      { path: 'personproduct', meta: { title: '单品管理' }, component: () => import('../views/shangpin/personproduct') },
      { path: 'advertise', meta: { title: '新闻管理' }, component: () => import('../views/xinwen/advertise') },
    ]

  },
  { path: '/login', component: () => import('../views/login') },
]



//创建路由实例
const router = new VueRouter({
  routes// `routes: routes` 的缩写
})

router.beforeEach((to, from, next) => {
  // ...
  // 返回 false 以取消导航
  // console.log(to,from);
  next()
  // return to
})
export default router